package org.come.Jpanel;

import com.tool.btn.FormsOnOffBtn;
import com.tool.btn.TtOperationBtn;
import com.tool.role.RoleData;
import com.tool.tcpimg.RichLabel;
import com.tool.tcpimg.UIUtils;

import java.awt.Component;
import java.awt.Graphics;
import java.awt.LayoutManager;
import java.math.BigDecimal;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

import org.come.bean.LoginResult;
import org.come.until.AnalysisString;
import org.come.until.CutButtonImage;


public class TtJpanel
        extends JPanel {
    private JLabel headImgLab;
    private JLabel nameLab;
    private JLabel lvLab;
    private JLabel jfLab;
    private JLabel tjLab;
    private JLabel currRankLab;
    private JLabel lastRankLab;
    private RichLabel sjInfo;
    private TtOperationBtn sjjlBtn;
    private TtOperationBtn fiveTimeBtn;
    private TtOperationBtn threeWinBtn;
    private TtOperationBtn fiveWinBtn;
    private TtOperationBtn jcBtn;
    private TtOperationBtn jfBtn;
    private TtOperationBtn intoGameBtn;
    private ImageIcon icon;

    public TtJpanel() {
        setBounds(176, 0, 674, 449);
        setOpaque(false);
        setLayout((LayoutManager) null);


        FormsOnOffBtn offBtn = new FormsOnOffBtn("inkImg/old/2/1.png", 1, 606);
        offBtn.setBounds(637, 10, 25, 25);
        add((Component) offBtn);


        this.headImgLab = new JLabel();
        this.nameLab = new JLabel();
        this.lvLab = new JLabel();
        this.jfLab = new JLabel();
        this.tjLab = new JLabel();
        this.currRankLab = new JLabel();
        this.lastRankLab = new JLabel();

        this.sjInfo = new RichLabel();

        this.sjjlBtn = new TtOperationBtn("skin/8100226/button/49.png", 1, UIUtils.COLOR_BTNPUTONG, "赛季奖励", UIUtils.TEXT_FONT1, 3, this);
        this.fiveTimeBtn = new TtOperationBtn("skin/8100226/button/B386.png", 1, 1, this);
        this.threeWinBtn = new TtOperationBtn("skin/8100226/button/B387.png", 1, 1, this);
        this.fiveWinBtn = new TtOperationBtn("skin/8100226/button/B388.png", 1, 1, this);
        this.jcBtn = new TtOperationBtn("skin/8100226/button/B389.png", 1, 5, this);
        this.jfBtn = new TtOperationBtn("skin/8100226/button/B390.png", 1, 6, this);
        this.intoGameBtn = new TtOperationBtn("skin/8100226/button/B391.png", 1, 1, this);


        this.headImgLab.setBounds(38, 63, 50, 50);
        this.nameLab.setBounds(152, 55, 120, 30);
        this.lvLab.setBounds(152, 86, 120, 30);
        this.jfLab.setBounds(152, 117, 120, 30);
        this.tjLab.setBounds(352, 55, 120, 30);
        this.currRankLab.setBounds(352, 86, 120, 30);
        this.lastRankLab.setBounds(352, 117, 120, 30);
        this.sjInfo.setBounds(31, 152, 500, 30);
        this.sjjlBtn.setBounds(31, 122, 68, 17);
        this.fiveTimeBtn.setBounds(450, 60, 80, 21);
        this.threeWinBtn.setBounds(450, 91, 80, 21);
        this.fiveWinBtn.setBounds(450, 122, 80, 21);
        this.jcBtn.setBounds(548, 60, 100, 19);
        this.jfBtn.setBounds(548, 91, 100, 19);
        this.intoGameBtn.setBounds(548, 122, 100, 19);


        add(this.headImgLab);
        add(this.nameLab);
        add(this.lvLab);
        add(this.jfLab);
        add(this.tjLab);
        add(this.currRankLab);
        add(this.lastRankLab);
        add((Component) this.sjInfo);
        add((Component) this.sjjlBtn);
        add((Component) this.fiveTimeBtn);
        add((Component) this.threeWinBtn);
        add((Component) this.fiveWinBtn);
        add((Component) this.jcBtn);
        add((Component) this.jfBtn);
        add((Component) this.intoGameBtn);

        initData();
    }

    public void initData() {
        this.sjInfo.setText("#R第一赛季");

        LoginResult data = RoleData.getRoleData().getLoginResult();

        this.headImgLab.setIcon(CutButtonImage.getImage("img/head/s" + getSpeciesId(data.getLocalname()) + ".png", 50, 50));
        this.nameLab.setText(data.getRolename());
        this.lvLab.setText(AnalysisString.lvl(data.getGrade().intValue()));
        this.jfLab.setText("入门0点");
        this.tjLab.setText("0/0");
        this.currRankLab.setText("0");
        this.lastRankLab.setText("未上榜");
    }


    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        if (this.icon == null) {
            this.icon = new ImageIcon("inkImg/old/background/S284.png");
        }
        g.drawImage(this.icon.getImage(), 0, 0, 674, 449, null);
    }


    public static BigDecimal getSpeciesId(String name) {
        if ("逍遥生".equals(name)) {
            return new BigDecimal(20001);
        }
        if ("剑侠客".equals(name)) {
            return new BigDecimal(20002);
        }
        if ("猛壮士".equals(name)) {
            return new BigDecimal(20003);
        }
        if ("飞燕女".equals(name)) {
            return new BigDecimal(20004);
        }
        if ("英女侠".equals(name)) {
            return new BigDecimal(20005);
        }
        if ("俏千金".equals(name)) {
            return new BigDecimal(20006);
        }
        if ("飞剑侠".equals(name)) {
            return new BigDecimal(20007);
        }
        if ("燕山雪".equals(name)) {
            return new BigDecimal(20008);
        }
        if ("纯阳子".equals(name)) {
            return new BigDecimal(20009);
        }
        if ("红拂女".equals(name)) {
            return new BigDecimal(20010);
        }
        if ("神秀生".equals(name)) {
            return new BigDecimal(20011);
        }
        if ("玲珑女".equals(name)) {
            return new BigDecimal(20012);
        }

        if ("虎头怪".equals(name)) {
            return new BigDecimal(21001);
        }
        if ("夺命妖".equals(name)) {
            return new BigDecimal(21002);
        }
        if ("巨魔王".equals(name)) {
            return new BigDecimal(21003);
        }
        if ("小蛮妖".equals(name)) {
            return new BigDecimal(21004);
        }
        if ("骨精灵".equals(name)) {
            return new BigDecimal(21005);
        }
        if ("狐美人".equals(name)) {
            return new BigDecimal(21006);
        }
        if ("逆天魔".equals(name)) {
            return new BigDecimal(21007);
        }
        if ("媚灵狐".equals(name)) {
            return new BigDecimal(21008);
        }
        if ("混天魔".equals(name)) {
            return new BigDecimal(21009);
        }
        if ("九尾狐".equals(name)) {
            return new BigDecimal(21010);
        }
        if ("绝影魔".equals(name)) {
            return new BigDecimal(21011);
        }
        if ("霜月灵".equals(name)) {
            return new BigDecimal(21012);
        }

        if ("神天兵".equals(name)) {
            return new BigDecimal(22001);
        }
        if ("智圣仙".equals(name)) {
            return new BigDecimal(22002);
        }
        if ("龙战将".equals(name)) {
            return new BigDecimal(22003);
        }
        if ("精灵仙".equals(name)) {
            return new BigDecimal(22004);
        }
        if ("舞天姬".equals(name)) {
            return new BigDecimal(22005);
        }
        if ("玄剑娥".equals(name)) {
            return new BigDecimal(22006);
        }
        if ("武尊神".equals(name)) {
            return new BigDecimal(22007);
        }
        if ("玄天姬".equals(name)) {
            return new BigDecimal(22008);
        }
        if ("紫薇神".equals(name)) {
            return new BigDecimal(22009);
        }
        if ("霓裳仙".equals(name)) {
            return new BigDecimal(22010);
        }
        if ("青阳使".equals(name)) {
            return new BigDecimal(22011);
        }
        if ("云中君".equals(name)) {
            return new BigDecimal(22012);
        }

        if ("祭剑魂".equals(name)) {
            return new BigDecimal(23001);
        }
        if ("猎魂引".equals(name)) {
            return new BigDecimal(23002);
        }
        if ("无崖子".equals(name)) {
            return new BigDecimal(23003);
        }
        if ("墨衣行".equals(name)) {
            return new BigDecimal(23004);
        }
        if ("夜溪灵".equals(name)) {
            return new BigDecimal(23005);
        }
        if ("幽梦影".equals(name)) {
            return new BigDecimal(23006);
        }
        if ("南冠客".equals(name)) {
            return new BigDecimal(23007);
        }
        if ("镜花影".equals(name)) {
            return new BigDecimal(23008);
        }

        if ("沧浪君".equals(name)) {
            return new BigDecimal(24001);
        }
        if ("龙渊客".equals(name)) {
            return new BigDecimal(24002);
        }
        if ("忘忧子".equals(name)) {
            return new BigDecimal(24003);
        }
        if ("骊珠儿".equals(name)) {
            return new BigDecimal(24004);
        }
        if ("木兰行".equals(name)) {
            return new BigDecimal(24005);
        }
        if ("莫解语".equals(name)) {
            return new BigDecimal(24006);
        }
        if ("游无极".equals(name)) {
            return new BigDecimal(24007);
        }
        if ("临九渊".equals(name)) {
            return new BigDecimal(24008);
        }
        return new BigDecimal(20001);
    }
}


